<template>
  <div>欢迎{{username}}</div>
  <a v-if="username" @click.prevent="signOut">注销</a>
</template>

<script>
export default {
  name: "Welcome",
  data(){
    return { username: '' }
  },
  beforeMount() {
    this.username = sessionStorage.getItem( 'user' );
  },
  methods: {
    signOut(){
      sessionStorage.removeItem( 'user' );
      this.$router.replace( '/sign/out' );
    }
  }
}
</script>

<style scoped>

</style>